<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    {{ include('@Admin/adminFramework/base/css.html.twig') | raw }}
    {% block hend %}{% endblock %}
    {% block css %}{% endblock %}
</head>
{% block body%}
<script>
    {% if session_type == 'redis'  %}
            //写cookies，一个小时过期
            function setCookie(name, value) {
                var exp = new Date();
                exp.setTime(exp.getTime() + 60 * 60 * 1000*24*30);
                document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/";
            }

            //读取cookies
            function getCookie(name) {
                var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");

                if (arr = document.cookie.match(reg))

                    return unescape(arr[2]);
                else
                    return null;
            }

            //删除
            function delCookie(name) {
                var exp = new Date();
                exp.setTime(exp.getTime() - 60 * 60 * 1000);
                var cval = getCookie(name);
                if (cval != null)
                    document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + ";path=/";
            }

            $(function(){
                var PHPREDISKEY = getCookie('PHPREDISKEY');
                if (PHPREDISKEY == null){
                    $.post('{{ path('service_resource_generateUuid') }}',{},function (result) {
                        if (result.errorCode == 1) {
                            alert('PHPREDISKEY存储失败');
                        } else {
                            var uuid = result.data.uuid;
                            setCookie('PHPREDISKEY',uuid);
                        }
                    })
                }
            });
    {% endif %}
</script>
    {% block jquery %}
    {% endblock %}
{% endblock %}
</html>

